home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CICA 1995 August
/
CICA - The Ultimate Collection of Shareware for Windows (Disc 2) (August 1995).iso
/
disc2
/
programr
/
stdg44.exe
/
lha
/
STDG.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-10
|
9KB
|
321 lines
/*
* Stdg
* ----
* Version 4 (c) Lachlan Patrick 1993
*
*/
/*
* Assume C declarations for C++
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Unsigned types.
*/
#ifndef _U_H
#define _U_H
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
#endif
/*
* Definition of Null
*/
#ifndef NULL
#define NULL (0)
#endif
/*
* Redefine main for portability and safety.
*/
#define main gmain
int main(int argc, char **argv);
/*
* Standard graphics library.
*/
#ifndef _STDG_H
#define _STDG_H
/*
* Types.
*/
typedef struct point point;
typedef struct rectangle rectangle;
typedef struct mouse mouse;
typedef struct bitmap bitmap;
typedef struct window window;
typedef struct menuitem menuitem;
typedef menuitem * menu;
typedef struct cursor cursor;
typedef struct font font;
typedef ulong pixval;
typedef void voidfn(void);
typedef void winfn(window *);
struct point
{
long x; /* horizontal co-ordinate */
long y; /* vertical co-ordinate */
};
struct rectangle
{
point min; /* top-left point inside rectangle */
point max; /* bottom-right outside rectangle */
};
struct mouse
{
uchar kind; /* mouse event kind bit array */
uchar buttons; /* mouse button state bit array: LMR=124 */
point xy; /* location of mouse */
};
struct bitmap
{
rectangle r; /* rectangle in data area, local coords */
short depth; /* depth = number of bits per pixel */
uchar * bits; /* bitmap data */
};
struct window
{
bitmap * b; /* bitmap for the window */
rectangle r; /* window rectangle on screen */
ushort flags; /* window appearance bit array */
short kind; /* user data can be stored here */
void * data; /* user data can be stored here */
winfn * close; /* called before window is closed */
winfn * resize; /* called after window is resized */
winfn * redraw; /* called when window must be redrawn */
};
struct menuitem
{
char * name; /* name of menu item, NULL=end of list */
ushort key; /* key equivalent, 0=none */
short * state; /* pointer to state variable */
voidfn * action; /* action to perform when item is chosen */
};
struct cursor
{
point offset; /* bitmap offset from mouse location */
uchar white[2*16]; /* white mask */
uchar black[2*16]; /* black shape */
void * cp; /* library data: initialise to NULL */
};
struct font
{
short height; /* height of a line */
short ascent; /* top of bitmap to baseline */
short descent; /* baseline to descender */
};
/*
* Colours.
*/
#define BLACK 0x00000000L
#define WHITE 0xFFFFFF00L
#define BLUE 0x0000FF00L
#define YELLOW 0xFFFF0000L
#define GREEN 0x00FF0000L
#define MAGENTA 0xFF00FF00L
#define RED 0xFF000000L
#define CYAN 0x00FFFF00L
#define GREY 0x7F7F7F00L
#define GRAY 0x7F7F7F00L
#define LTGREY 0xBFBFBF00L
#define LTGRAY 0xBFBFBF00L
#define DKGREY 0x3F3F3F00L
#define DKGRAY 0x3F3F3F00L
/*
* Transfer codes for drawing operations.
*/
#define Zeros 0x00
#define DnorS 0x01
#define DandnotS 0x02
#define notS 0x03
#define notDandS 0x04
#define notD 0x05
#define DxorS 0x06
#define DnandS 0x07
#define DandS 0x08
#define DxnorS 0x09
#define D 0x0A
#define DornotS 0x0B
#define S 0x0C
#define notDorS 0x0D
#define DorS 0x0E
#define Ones 0x0F
/*
* Mouse buttons and event constants.
*/
#define NoButton 0x00
#define LeftButton 0x01
#define MiddleButton 0x02
#define RightButton 0x04
#define MouseMove 0x00
#define MouseDown 0x10
#define MouseUp 0x20
#define MouseTimer 0x40
#define DoubleClick 0x80
#define LeftButtonDown (MouseDown | LeftButton)
#define MiddleButtonDown (MouseDown | MiddleButton)
#define RightButtonDown (MouseDown | RightButton)
#define LeftButtonUp (MouseUp | LeftButton)
#define MiddleButtonUp (MouseUp | MiddleButton)
#define RightButtonUp (MouseUp | RightButton)
/*
* Window flags.
*/
#define Simple 0x0000
#define Visible 0x0001
#define Buffered 0x0002
#define Titlebar 0x0004
#define Closebox 0x0008
#define Maximize 0x0010
#define Resize 0x0020
#define Attentive 0x0040
#define DoubleClicks 0x0080
#define Modal 0x0100
#define Floating 0x0200
#define Workspace 0x0400
#define Document 0x0800
/*
* Menu item states.
*/
#define Disabled 0x00
#define Enabled 0x01
#define Ticked 0x02
/*
* Function prototypes.
*/
void ginit(char *name, voidfn *update_menus, menu menus[]);
void gexit(void);
void gflush(void);
extern void (*gerror)(char *errstr);
#define dx(r) ((r).max.x-(r).min.x)
#define dy(r) ((r).max.y-(r).min.y)
point pt(long x, long y);
rectangle rect(long minx, long miny, long maxx, long maxy);
rectangle rdiag(long minx, long miny, long width, long height);
rectangle rpt(point min, point max);
point addp(point p1, point p2);
point subp(point p1, point p2);
point mulp(point p, long i);
point divp(point p, long i);
rectangle raddp(rectangle r, point p);
rectangle rsubp(rectangle r, point p);
rectangle mulr(rectangle r, long i);
rectangle divr(rectangle r, long i);
rectangle insetr(rectangle r, long i);
rectangle rcanon(rectangle r);
short pinr(point p, rectangle r);
short rxr(rectangle r1, rectangle r2);
short eqp(point p1, point p2);
short eqr(rectangle r1, rectangle r2);
short rclip(rectangle *r1, rectangle r2);
void bit_copy(bitmap *db, point p, bitmap *sb, rectangle r, pixval v);
void texture_rect(bitmap *db, rectangle r, bitmap *sb, pixval v);
void invert_rect(bitmap *db, rectangle r);
void fill_rect(bitmap *db, rectangle r, pixval v);
void draw_rect(bitmap *db, rectangle r, long w, pixval v);
void draw_point(bitmap *db, point p, pixval v);
void draw_line(bitmap *db, point p1, point p2, pixval v);
void draw_arc(bitmap *db, point p0, point p1, point p2, pixval v);
void fill_circle(bitmap *db, point p, long r, pixval v);
void draw_circle(bitmap *db, point p, long r, pixval v);
void fill_ellipse(bitmap *db, point p, long r1, long r2, pixval v);
void draw_ellipse(bitmap *db, point p, long r1, long r2, pixval v);
point draw_string(bitmap *db, point p, font *f, char *s, pixval v);
long strwidth(font *f, char *s);
point strsize(font *f, char *s);
bitmap *new_bitmap(rectangle r, short depth);
bitmap *get_bitmap(char *name, short depth);
void del_bitmap(bitmap *b);
window *new_window(char *name, rectangle r, ushort flags);
void set_winfns(window *w, winfn *close, winfn *size, winfn *draw);
void set_winname(window *w, char *newname);
void del_window(window *w);
void show_window(window *w);
void hide_window(window *w);
short start_timer(long msec);
short set_mouse_delay(long msec);
void delay(long msec);
short can_event(void);
short can_timer(void);
short can_mouse(window *w);
short can_key(window *w);
long get_timer(void);
mouse get_mouse(window *w);
ushort get_key(window *w);
void unget_mouse(window *w, mouse m);
void unget_key(window *w, ushort k);
cursor *get_cursor(char *name);
void set_cursor(cursor *c);
font * get_font(char *name, char *style, ushort size);
/*
* Library supplied variables.
*/
extern bitmap *screen;
extern font *sys_font;
extern font *fixed_font;
extern cursor *current_cursor;
extern window *active_window;
extern short menu_item;
#endif
#ifdef __cplusplus
}
#endif